/***********************************************
 This file is part of redia-lib-utils-ios
.
 
 Copyright (c) 2014 Redia A/S
 
 Redia-library-app-ios is free software: you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
 the Free Software Foundation, either version 3 of the License, or
 (at your option) any later version.
 
 Redia-library-app-ios is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.
 
 You should have received a copy of the GNU General Public License
 along with redia-library-app-ios.  If not, see <http://www.gnu.org/licenses/>.
 
 *********************************************** */

#import <Foundation/Foundation.h>
#import "LazyLoadConnection.h"
#import "defines.h"

@interface LazyLoadManager : NSObject

SINGLETON_DECL_GCD(LazyLoadManager)

- (void)lazyLoadUIImageFromUrl:(NSString*)url setScaleforRetina:(BOOL)setScaleforRetina onSuccess:(LLSuccessBlock)successBlock onError:(LLErrorBlock)errorBlock;
- (void)lazyLoadUIImageFromUrl:(NSString*)url withOwner:(id)owner setScaleforRetina:(BOOL)setScaleforRetina onSuccess:(LLSuccessBlock)successBlock onError:(LLErrorBlock)errorBlock;
- (void)lazyLoadUIImageFromUrl:(NSString*)url withOwner:(id)owner setScaleforRetina:(BOOL)setScaleforRetina onSuccess:(LLSuccessBlock)successBlock onError:(LLErrorBlock)errorBlock onCancel:(LLCancelBlock)cancelBlock;

/**
 * Cancels all ongoing connections owned by the given object.
 * @param owner The object that supposedly owns some connections.
 */
- (void)cancelConnectionsForOwner:(id)owner;

/**
 * Cancels all ongoing orphaned connections. 
 * @note Use this with caution - it cancels _all_ orphaned connections so you need
 * to be certain that you are not cancelling too much.
 */
- (void)cancelOrphanedConnections;

/**
 * Cancels all ongoing connections - owned and orphaned alike.
 * @note Use this with caution - it cancels _all_ connections so you need
 * to be certain that you are not cancelling too much.
 */
- (void)cancelAllConnections;

/**
 * Cancel a specific connection.
 * @param connection The connection to cancel.
 */
- (void)cancelConnection:(LazyLoadConnection*)connection;

/**
 * Removes a connection object.
 */
- (void)removeConnection:(LazyLoadConnection*)connection;

@end
